package org.odk.clinic.android.activities;

import org.odk.clinic.android.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.TextView;

public class MainActivity extends Activity{
	private static final int Openmrs1 = 0;
	private static final int Openmrs2 = 1;
	@Override
	protected void onCreate(Bundle ici){
		super.onCreate(ici);
		setContentView(R.layout.main_menu);
		setTitle(getString(R.string.app_name) + ">" + getString(R.string.main));
		TextView text = (TextView)this.findViewById(R.id.menu_id);
		text.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
			
			@Override
			public void onCreateContextMenu(ContextMenu menu, View v,
					ContextMenuInfo menuInfo) {
				// TODO Auto-generated method stub
				menu.add(0,0,0, "Openmrs1");
				menu.add(0,1,1, "Openmrs2");
			}
		});
		text.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				openContextMenu(v);
			}
		});
		
		
	}
	@Override
	public boolean onContextItemSelected(MenuItem item){
		AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
		switch(item.getItemId()){
		case Openmrs1 :
			Intent i = new Intent(MainActivity.this,ListPatientActivity.class);
			startActivity(i);break;
		case Openmrs2 :
			Intent j = new Intent(MainActivity.this,ListPatientActivity2.class);
			startActivity(j);break;
		default :
			return super.onContextItemSelected(item);
		}
		return true;
	}

}
